package Interfaz;
import Logica.*;
import Algoritmos.AlgIngenuo;
import java.awt.*;
import java.util.ArrayList;
import javax.swing.*;
import javax.swing.UIManager;
import de.muntjak.tinylookandfeel.*;
import java.io.BufferedWriter;
import java.io.DataOutputStream;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.util.Vector;
import javax.swing.plaf.metal.DefaultMetalTheme;
import javax.swing.plaf.metal.MetalLookAndFeel;
/*
 * VentanaPrincipal.java
 *
 * Created on 26/04/2011, 01:06:56 PM
 */
/**
 * Interfaz grafica de la aplicaciion
 * @author  Miguel Mondragon 
 * @since  1.0
 */
public class VentanaPrincipal extends javax.swing.JFrame {
    private String salidaingenuo="";
    /** 
     * Crea una nueva ventana principal y establece su apariencia
     *
     */
    public VentanaPrincipal() {
        initComponents();
        this.setIconImage(new ImageIcon(getClass().getResource("images/planogeneral.jpg")).getImage());
        this.setLocationRelativeTo(null);
        vntInfo=new VentanaInfo(this,false);
        try{
           UIManager.setLookAndFeel("de.muntjak.tinylookandfeel.TinyLookAndFeel");
            MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());
           SwingUtilities.updateComponentTreeUI(this);
        }catch (Exception e){
                e.printStackTrace();
        }
    }
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jSeparator1 = new javax.swing.JSeparator();
        btAbrir = new javax.swing.JButton();
        btAlgIngenuo = new javax.swing.JButton();
        btAlgComprobador = new javax.swing.JButton();
        btAlgAyuda = new javax.swing.JButton();
        scrlPnlMapa = new javax.swing.JScrollPane();
        pnlMapa = new Mapa();
        btAbrir1 = new javax.swing.JButton();
        btGuardar = new javax.swing.JButton();
        mnbPrincipal = new javax.swing.JMenuBar();
        mnuArchivo = new javax.swing.JMenu();
        mnuitemAbrir = new javax.swing.JMenuItem();
        mnuItemAbrir2 = new javax.swing.JMenuItem();
        mnuItemGuardar = new javax.swing.JMenuItem();
        mnuitemSalir = new javax.swing.JMenuItem();
        mnuVer = new javax.swing.JMenu();
        mnuitemIngenuo = new javax.swing.JMenuItem();
        mnuitemComprobar = new javax.swing.JMenuItem();
        mnuAyuda = new javax.swing.JMenu();
        mnuitemAcerca = new javax.swing.JMenuItem();
        mnuitemAyuda = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("SARUM");
        setFocusable(false);
        setForeground(java.awt.Color.white);
        setIconImages(null);
        setName("vntPrincipal"); // NOI18N
        setResizable(false);

        btAbrir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interfaz/images/abrir.png")));
        btAbrir.setText("Paradas y Rutas");
        btAbrir.setToolTipText("Abrir Paradas y Rutas");
        btAbrir.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btAbrir.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
        btAbrir.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btAbrir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btAbrirActionPerformed(evt);
            }
        });

        btAlgIngenuo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interfaz/images/ingenuo.png")));
        btAlgIngenuo.setText("Algoritmo Ingenuo");
        btAlgIngenuo.setToolTipText("AlgIngenuo");
        btAlgIngenuo.setEnabled(false);
        btAlgIngenuo.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btAlgIngenuo.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
        btAlgIngenuo.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btAlgIngenuo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btAlgIngenuoActionPerformed(evt);
            }
        });

        btAlgComprobador.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interfaz/images/comprobador.png")));
        btAlgComprobador.setText("Comprobador");
        btAlgComprobador.setToolTipText("Comprobador");
        btAlgComprobador.setEnabled(false);
        btAlgComprobador.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btAlgComprobador.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
        btAlgComprobador.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btAlgComprobador.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btAlgComprobadorActionPerformed(evt);
            }
        });

        btAlgAyuda.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interfaz/images/ayuda.png")));
        btAlgAyuda.setText("Ayuda");
        btAlgAyuda.setToolTipText("Ayuda");
        btAlgAyuda.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btAlgAyuda.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
        btAlgAyuda.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btAlgAyuda.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btAlgAyudaActionPerformed(evt);
            }
        });

        scrlPnlMapa.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED), "Mapa", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 1, 14))); // NOI18N
        scrlPnlMapa.setToolTipText("mapa");
        scrlPnlMapa.setEnabled(false);

        pnlMapa.setCursor(new java.awt.Cursor(java.awt.Cursor.CROSSHAIR_CURSOR));
        pnlMapa.setDoubleBuffered(false);
        pnlMapa.setEnabled(false);
        pnlMapa.setFocusable(false);

        javax.swing.GroupLayout pnlMapaLayout = new javax.swing.GroupLayout(pnlMapa);
        pnlMapa.setLayout(pnlMapaLayout);
        pnlMapaLayout.setHorizontalGroup(
            pnlMapaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 921, Short.MAX_VALUE)
        );
        pnlMapaLayout.setVerticalGroup(
            pnlMapaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 429, Short.MAX_VALUE)
        );

        scrlPnlMapa.setViewportView(pnlMapa);

        btAbrir1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interfaz/images/abrir2.png")));
        btAbrir1.setText("Origenes y Destinos");
        btAbrir1.setToolTipText("Abrir Origenes y Destinos");
        btAbrir1.setEnabled(false);
        btAbrir1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btAbrir1.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
        btAbrir1.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btAbrir1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btAbrir1ActionPerformed(evt);
            }
        });

        btGuardar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interfaz/images/guardar.png")));
        btGuardar.setText("Guardar Salida");
        btGuardar.setToolTipText("Guardar Salida");
        btGuardar.setEnabled(false);
        btGuardar.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btGuardar.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
        btGuardar.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btGuardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btGuardarActionPerformed(evt);
            }
        });

        mnuArchivo.setText("Archivo");

        mnuitemAbrir.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_A, java.awt.event.InputEvent.CTRL_MASK));
        mnuitemAbrir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interfaz/images/abrir.png")));
        mnuitemAbrir.setText("Abrir");
        mnuitemAbrir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mnuitemAbrirActionPerformed(evt);
            }
        });
        mnuArchivo.add(mnuitemAbrir);

        mnuItemAbrir2.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Q, java.awt.event.InputEvent.CTRL_MASK));
        mnuItemAbrir2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interfaz/images/abrir2.png")));
        mnuItemAbrir2.setText("Abrir O&D");
        mnuItemAbrir2.setEnabled(false);
        mnuItemAbrir2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mnuItemAbrir2ActionPerformed(evt);
            }
        });
        mnuArchivo.add(mnuItemAbrir2);

        mnuItemGuardar.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK));
        mnuItemGuardar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interfaz/images/guardar.png")));
        mnuItemGuardar.setText("Guardar");
        mnuItemGuardar.setEnabled(false);
        mnuItemGuardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mnuItemGuardarActionPerformed(evt);
            }
        });
        mnuArchivo.add(mnuItemGuardar);

        mnuitemSalir.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F4, java.awt.event.InputEvent.ALT_MASK));
        mnuitemSalir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interfaz/images/salir.png")));
        mnuitemSalir.setText("Salir");
        mnuitemSalir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mnuitemSalirActionPerformed(evt);
            }
        });
        mnuArchivo.add(mnuitemSalir);

        mnbPrincipal.add(mnuArchivo);

        mnuVer.setText("Ver");

        mnuitemIngenuo.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_I, java.awt.event.InputEvent.ALT_MASK));
        mnuitemIngenuo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interfaz/images/ingenuo.png")));
        mnuitemIngenuo.setText("Ingenuo");
        mnuitemIngenuo.setEnabled(false);
        mnuitemIngenuo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mnuitemIngenuoActionPerformed(evt);
            }
        });
        mnuVer.add(mnuitemIngenuo);

        mnuitemComprobar.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.ALT_MASK));
        mnuitemComprobar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interfaz/images/comprobador.png")));
        mnuitemComprobar.setText("Comprobar");
        mnuitemComprobar.setEnabled(false);
        mnuVer.add(mnuitemComprobar);

        mnbPrincipal.add(mnuVer);

        mnuAyuda.setText("Ayuda");

        mnuitemAcerca.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F2, 0));
        mnuitemAcerca.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interfaz/images/acercade.png")));
        mnuitemAcerca.setText("Acerca de");
        mnuitemAcerca.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mnuitemAcercaActionPerformed(evt);
            }
        });
        mnuAyuda.add(mnuitemAcerca);

        mnuitemAyuda.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F1, 0));
        mnuitemAyuda.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Interfaz/images/ayuda.png")));
        mnuitemAyuda.setText("Ayuda");
        mnuitemAyuda.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mnuitemAyudaActionPerformed(evt);
            }
        });
        mnuAyuda.add(mnuitemAyuda);

        mnbPrincipal.add(mnuAyuda);

        setJMenuBar(mnbPrincipal);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(btAbrir, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btAbrir1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btGuardar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btAlgIngenuo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btAlgComprobador, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(110, 110, 110)
                .addComponent(btAlgAyuda, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
            .addGroup(layout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addComponent(scrlPnlMapa, javax.swing.GroupLayout.DEFAULT_SIZE, 758, Short.MAX_VALUE)
                .addGap(10, 10, 10))
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 758, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                            .addComponent(btAbrir1, 0, 0, Short.MAX_VALUE)
                            .addComponent(btGuardar, javax.swing.GroupLayout.DEFAULT_SIZE, 52, Short.MAX_VALUE)
                            .addComponent(btAlgIngenuo, javax.swing.GroupLayout.DEFAULT_SIZE, 52, Short.MAX_VALUE)
                            .addComponent(btAlgComprobador, javax.swing.GroupLayout.DEFAULT_SIZE, 52, Short.MAX_VALUE)
                            .addComponent(btAbrir, javax.swing.GroupLayout.DEFAULT_SIZE, 52, Short.MAX_VALUE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(11, 11, 11)
                        .addComponent(btAlgAyuda, javax.swing.GroupLayout.DEFAULT_SIZE, 52, Short.MAX_VALUE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 10, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(scrlPnlMapa, javax.swing.GroupLayout.DEFAULT_SIZE, 458, Short.MAX_VALUE)
                .addContainerGap())
        );

        getAccessibleContext().setAccessibleDescription("vntPrincipal de SARUM");

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btAlgComprobadorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btAlgComprobadorActionPerformed

    }//GEN-LAST:event_btAlgComprobadorActionPerformed

    private void btAbrirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btAbrirActionPerformed
        try{
            JFileChooser fileChooser = new JFileChooser();
            int seleccion = fileChooser.showOpenDialog(this);
            if (seleccion == JFileChooser.APPROVE_OPTION){
                objCargarArchivo=new CargarArchivo(fileChooser.getSelectedFile());
                    objCargarArchivo.computarArchivo();
                    graficarMapa(objCargarArchivo.getFileParadas(),objCargarArchivo.getFileRutas());
                    vntInfo.informararchivo(objCargarArchivo.getFileParadas(),objCargarArchivo.getFileRutas());
                    this.btAbrir1.setEnabled(true);
                    this.mnuItemAbrir2.setEnabled(true);
            }
        }catch(Exception ex){
            System.err.println("Ha ocurrido un problema al cargar el archivo: "+ex);
            JOptionPane.showMessageDialog(this,"Ha ocurrido un problema al cargar el archivo");
        }
    }//GEN-LAST:event_btAbrirActionPerformed

    private void btAlgAyudaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btAlgAyudaActionPerformed
        JDialog dialog= new JDialog(this, "", true);
        dialog.setTitle("Ayuda");
        JTextArea label = new JTextArea(":\n" +
						"\n" +
                                               	"\n" +
                                               	"\n");
        label.setEditable(false);
        Container contentPane = dialog.getContentPane();
                    contentPane.add(label, BorderLayout.CENTER);
                    dialog.setSize(new Dimension(300, 500));
                    dialog.setLocationRelativeTo(this);
                    dialog.setVisible(true);
    }//GEN-LAST:event_btAlgAyudaActionPerformed

    private void mnuitemSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mnuitemSalirActionPerformed
        System.exit(0);
    }//GEN-LAST:event_mnuitemSalirActionPerformed

    private void mnuitemAbrirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mnuitemAbrirActionPerformed
        try{
            JFileChooser fileChooser = new JFileChooser();
            int seleccion = fileChooser.showOpenDialog(this);
            if (seleccion == JFileChooser.APPROVE_OPTION){
                objCargarArchivo=new CargarArchivo(fileChooser.getSelectedFile());
                    objCargarArchivo.computarArchivo();
                    graficarMapa(objCargarArchivo.getFileParadas(),objCargarArchivo.getFileRutas());
                    vntInfo.informararchivo(objCargarArchivo.getFileParadas(),objCargarArchivo.getFileRutas());
                    this.btAbrir1.setEnabled(true);
                    this.mnuItemAbrir2.setEnabled(true);
            }
        }catch(Exception ex){
            System.err.println("Ha ocurrido un problema al cargar el archivo: "+ex);
            JOptionPane.showMessageDialog(this,"Ha ocurrido un problema al cargar el archivo");
        }
    }//GEN-LAST:event_mnuitemAbrirActionPerformed

    private void mnuitemAyudaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mnuitemAyudaActionPerformed
       JDialog dialog= new JDialog(this, "", true);
        dialog.setTitle("Ayuda");
        JTextArea label = new JTextArea(":\n" +
						"\n" +
                                               	"\n" +
                                               	"\n");
        label.setEditable(false);
        Container contentPane = dialog.getContentPane();
                    contentPane.add(label, BorderLayout.CENTER);
                    dialog.setSize(new Dimension(300, 500));
                    dialog.setLocationRelativeTo(this);
                    dialog.setVisible(true);
    }//GEN-LAST:event_mnuitemAyudaActionPerformed

    private void mnuitemAcercaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mnuitemAcercaActionPerformed
       JDialog dialog= new JDialog(this, "", true);
       dialog.setTitle("Ayuda");
       JTextPane label = new JTextPane();
       label.setContentType("text/html");
            label.setText("<center><font size=15><strong>S.A.R.U.M.</strong></font><br/>"+
                                "Sugerencia Automatizada de Rutas a Usuarios del MIO</center><br/>"+
                                "<b>Product Version:</b> SARUM (Build 20110428)<br/>"+
                                "<b>Java:</b>"+System.getProperty("java.version")+"<br/>"+
                                "<b>System:</b>"+System.getProperty("os.name")+"<br/>"+
                                "<b>Userdir:</b>"+System.getProperty("user.dir")+"<br/>");
        JLabel img = new JLabel("Plano");
            img.setIcon(new ImageIcon("planogeneral.jpg"));
            label.insertComponent(img);
        label.setEditable(false);
        Container contentPane = dialog.getContentPane();
                    contentPane.add(label, BorderLayout.CENTER);
                    dialog.setSize(new Dimension(500,300));
                    dialog.setLocationRelativeTo(this);
                    dialog.setVisible(true);
    }//GEN-LAST:event_mnuitemAcercaActionPerformed

    private void btAlgIngenuoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btAlgIngenuoActionPerformed
        this.salidaingenuo= new AlgIngenuo(objCargarArchivo.getFileParadas()).calcularIngenuo(origendestino,objCargarArchivo.getFileRutas().getDestinosRuta());
        this.mnuitemComprobar.setEnabled(true);
        this.btAlgComprobador.setEnabled(true);
        this.mnuItemGuardar.setEnabled(true);
        this.btGuardar.setEnabled(true);
    }//GEN-LAST:event_btAlgIngenuoActionPerformed

    private void btAbrir1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btAbrir1ActionPerformed
        try{
            JFileChooser fileChooser = new JFileChooser();
            int seleccion = fileChooser.showOpenDialog(this);
            if (seleccion == JFileChooser.APPROVE_OPTION){
                origendestino = objCargarArchivo.cargarProblema(fileChooser.getSelectedFile());
                /**for(int a=0;a<origendestino.size();a++){
                    System.out.print("TEST: "+origendestino.get(a)[0]+" -> "+origendestino.get(a)[1]+"\n");
                }*/
                vntInfo.informararchivo2(origendestino);
                this.mnuitemIngenuo.setEnabled(true);
                this.btAlgIngenuo.setEnabled(true);
            }
        }catch(Exception ioex){
            System.err.println("Ha ocurrido un problema al cargar el archivo: "+ioex);
            JOptionPane.showMessageDialog(this,"Ha ocurrido un problema al cargar el archivo \n");
        }
    }//GEN-LAST:event_btAbrir1ActionPerformed

    private void btGuardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btGuardarActionPerformed
           try{
               JFileChooser fileChooser = new JFileChooser();
               int seleccion = fileChooser.showSaveDialog(this);
                    fileChooser.setCurrentDirectory(new  java.io.File("."));
                    fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            if (seleccion == JFileChooser.APPROVE_OPTION){
                DataOutputStream out=new DataOutputStream(new FileOutputStream(fileChooser.getSelectedFile()+".txt"));
                out.writeUTF(salidaingenuo);
                vntInfo.informararchivo3(salidaingenuo);
                System.out.println(this.salidaingenuo);
            }
        }catch(Exception ioex){
            System.err.println("Ha ocurrido un problema al guardar el archivo: "+ioex);
            JOptionPane.showMessageDialog(this,"Ha ocurrido un problema al cargar el archivo \n");
        }
    }//GEN-LAST:event_btGuardarActionPerformed

    private void mnuItemGuardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mnuItemGuardarActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_mnuItemGuardarActionPerformed

    private void mnuItemAbrir2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mnuItemAbrir2ActionPerformed
        try{
            JFileChooser fileChooser = new JFileChooser();
            int seleccion = fileChooser.showOpenDialog(this);
            if (seleccion == JFileChooser.APPROVE_OPTION){
                origendestino = objCargarArchivo.cargarProblema(fileChooser.getSelectedFile());
                /*for(int a=0;a<origendestino.size();a++){
                    System.out.print("TEST: "+origendestino.get(a)[0]+" -> "+origendestino.get(a)[1]);
                }*/
                vntInfo.informararchivo2(origendestino);
                this.mnuitemIngenuo.setEnabled(true);
                this.btAlgIngenuo.setEnabled(true);
            }
        }catch(Exception ioex){
            System.err.println("Ha ocurrido un problema al cargar el archivo: "+ioex);
            JOptionPane.showMessageDialog(this,"Ha ocurrido un problema al cargar el archivo");
        }
    }//GEN-LAST:event_mnuItemAbrir2ActionPerformed

    private void mnuitemIngenuoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mnuitemIngenuoActionPerformed
        this.mnuitemComprobar.setEnabled(true);
        this.btAlgComprobador.setEnabled(true);
        this.mnuItemGuardar.setEnabled(true);
        this.btGuardar.setEnabled(true);
    }//GEN-LAST:event_mnuitemIngenuoActionPerformed
    private void graficarMapa(SarumParadas fileParadas, SarumRutas fileRutas){
        pnlMapa.clearFiguras();
        for(int rtua=0;rtua<fileRutas.sizeRutas();rtua++){
            Ruta rta=(Ruta)fileRutas.getListaRutas().get(rtua);
            for(int j=0;j<rta.getListParejas().size()-1;j++){
                ViaTroncal vtrc=new ViaTroncal(fileParadas.getPosicion(rta.getListParejas().get(j).y),fileParadas.getPosicion(rta.getListParejas().get(j+1).y),rta.getListParejas().get(j+1).x);
                pnlMapa.addFigura(vtrc);
            }
        }
        for(int estac=0;estac<fileParadas.sizeParadas();estac++){
            Parada prd=(Parada)fileParadas.getListaParadas().get(estac);
            Estacion est=new Estacion(prd.getUbicacion().x,prd.getUbicacion().y,prd.getNParada()+"",prd.getTipoParada());
            pnlMapa.addFigura(est);
        }
    }
    private VentanaInfo vntInfo;
    private ArrayList<Point[]> origendestino;
    private CargarArchivo objCargarArchivo;
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btAbrir;
    private javax.swing.JButton btAbrir1;
    private javax.swing.JButton btAlgAyuda;
    private javax.swing.JButton btAlgComprobador;
    private javax.swing.JButton btAlgIngenuo;
    private javax.swing.JButton btGuardar;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JMenuBar mnbPrincipal;
    private javax.swing.JMenu mnuArchivo;
    private javax.swing.JMenu mnuAyuda;
    private javax.swing.JMenuItem mnuItemAbrir2;
    private javax.swing.JMenuItem mnuItemGuardar;
    private javax.swing.JMenu mnuVer;
    private javax.swing.JMenuItem mnuitemAbrir;
    private javax.swing.JMenuItem mnuitemAcerca;
    private javax.swing.JMenuItem mnuitemAyuda;
    private javax.swing.JMenuItem mnuitemComprobar;
    private javax.swing.JMenuItem mnuitemIngenuo;
    private javax.swing.JMenuItem mnuitemSalir;
    private Mapa pnlMapa;
    private javax.swing.JScrollPane scrlPnlMapa;
    // End of variables declaration//GEN-END:variables


}
